inline int min(const int x, const int y) {
    if (x < y) return x;
    return y;
}

int minimumTotal(int** triangle, int triangleRowSize, int *triangleColSizes) {
    int i, j;
    for (i = triangleRowSize-2; i >= 0; i--)
        for (j = 0; j <= i; j++)
        {
            triangle[i][j] += min(triangle[i+1][j], triangle[i+1][j+1]);
        }
    return triangle[0][0];
}
